package com.bwie.es;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

@Data
@Document(indexName = "es_log", shards = 1, replicas = 0)
public class EsLog implements Serializable {
    /**
     * 日志ID
     */
    @Id
    @Field(type = FieldType.Integer)
    private Integer logId;

    /**
     * 操作者
     */
    @Field(type = FieldType.Keyword)
    private String logOpt;

    /**
     * 日志时间
     */
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "yyyy-MM-dd HH:mm:ss" )
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date logTime;

    /**
     * 操作者IP
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String logIp;

    /**
     * 日志内容
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String logContent;

    private static final long serialVersionUID = 1L;
}
